<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - Lua 5.4.0-alpha - src/lundump.c</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../index.html">top level</a> - <a href="index.html">src</a> - lundump.c</td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">Lua 5.4.0-alpha</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">160</td>
            <td class="headerCovTableEntry">178</td>
            <td class="headerCovTableEntryMed">89.9 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2019-06-13 19:44:19</td>
            <td></td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<span class="lineNum">       1 </span>            : /*
<span class="lineNum">       2 </span>            : ** $Id: lundump.c $
<span class="lineNum">       3 </span>            : ** load precompiled Lua chunks
<span class="lineNum">       4 </span>            : ** See Copyright Notice in lua.h
<span class="lineNum">       5 </span>            : */
<span class="lineNum">       6 </span>            : 
<span class="lineNum">       7 </span>            : #define lundump_c
<span class="lineNum">       8 </span>            : #define LUA_CORE
<span class="lineNum">       9 </span>            : 
<span class="lineNum">      10 </span>            : #include &quot;lprefix.h&quot;
<span class="lineNum">      11 </span>            : 
<span class="lineNum">      12 </span>            : 
<span class="lineNum">      13 </span>            : #include &lt;limits.h&gt;
<span class="lineNum">      14 </span>            : #include &lt;string.h&gt;
<span class="lineNum">      15 </span>            : 
<span class="lineNum">      16 </span>            : #include &quot;lua.h&quot;
<span class="lineNum">      17 </span>            : 
<span class="lineNum">      18 </span>            : #include &quot;ldebug.h&quot;
<span class="lineNum">      19 </span>            : #include &quot;ldo.h&quot;
<span class="lineNum">      20 </span>            : #include &quot;lfunc.h&quot;
<span class="lineNum">      21 </span>            : #include &quot;lmem.h&quot;
<span class="lineNum">      22 </span>            : #include &quot;lobject.h&quot;
<span class="lineNum">      23 </span>            : #include &quot;lstring.h&quot;
<span class="lineNum">      24 </span>            : #include &quot;lundump.h&quot;
<span class="lineNum">      25 </span>            : #include &quot;lzio.h&quot;
<span class="lineNum">      26 </span>            : 
<span class="lineNum">      27 </span>            : 
<span class="lineNum">      28 </span>            : #if !defined(luai_verifycode)
<span class="lineNum">      29 </span>            : #define luai_verifycode(L,b,f)  /* empty */
<span class="lineNum">      30 </span>            : #endif
<span class="lineNum">      31 </span>            : 
<span class="lineNum">      32 </span>            : 
<span class="lineNum">      33 </span>            : typedef struct {
<span class="lineNum">      34 </span>            :   lua_State *L;
<span class="lineNum">      35 </span>            :   ZIO *Z;
<span class="lineNum">      36 </span>            :   const char *name;
<span class="lineNum">      37 </span>            : } LoadState;
<span class="lineNum">      38 </span>            : 
<span class="lineNum">      39 </span>            : 
<span class="lineNum">      40 </span><span class="lineCov">          4 : static l_noret error (LoadState *S, const char *why) {</span>
<span class="lineNum">      41 </span><span class="lineCov">          4 :   luaO_pushfstring(S-&gt;L, &quot;%s: bad binary format (%s)&quot;, S-&gt;name, why);</span>
<span class="lineNum">      42 </span><span class="lineCov">          4 :   luaD_throw(S-&gt;L, LUA_ERRSYNTAX);</span>
<span class="lineNum">      43 </span>            : }
<span class="lineNum">      44 </span>            : 
<span class="lineNum">      45 </span>            : 
<span class="lineNum">      46 </span>            : /*
<span class="lineNum">      47 </span>            : ** All high-level loads go through LoadVector; you can change it to
<span class="lineNum">      48 </span>            : ** adapt to the endianness of the input
<span class="lineNum">      49 </span>            : */
<span class="lineNum">      50 </span>            : #define LoadVector(S,b,n)       LoadBlock(S,b,(n)*sizeof((b)[0]))
<span class="lineNum">      51 </span>            : 
<span class="lineNum">      52 </span><span class="lineCov">        112 : static void LoadBlock (LoadState *S, void *b, size_t size) {</span>
<span class="lineNum">      53 </span><span class="lineCov">        112 :   if (luaZ_read(S-&gt;Z, b, size) != 0)</span>
<span class="lineNum">      54 </span><span class="lineNoCov">          0 :     error(S, &quot;truncated chunk&quot;);</span>
<span class="lineNum">      55 </span><span class="lineCov">        112 : }</span>
<span class="lineNum">      56 </span>            : 
<span class="lineNum">      57 </span>            : 
<span class="lineNum">      58 </span>            : #define LoadVar(S,x)            LoadVector(S,&amp;x,1)
<span class="lineNum">      59 </span>            : 
<span class="lineNum">      60 </span>            : 
<span class="lineNum">      61 </span><span class="lineCov">        343 : static lu_byte LoadByte (LoadState *S) {</span>
<span class="lineNum">      62 </span><span class="lineCov">        343 :   int b = zgetc(S-&gt;Z);</span>
<span class="lineNum">      63 </span><span class="lineCov">        343 :   if (b == EOZ)</span>
<span class="lineNum">      64 </span><span class="lineCov">          1 :     error(S, &quot;truncated chunk&quot;);</span>
<span class="lineNum">      65 </span><span class="lineCov">        342 :   return cast_byte(b);</span>
<span class="lineNum">      66 </span>            : }
<span class="lineNum">      67 </span>            : 
<span class="lineNum">      68 </span>            : 
<span class="lineNum">      69 </span><span class="lineCov">        196 : static size_t LoadUnsigned (LoadState *S, size_t limit) {</span>
<span class="lineNum">      70 </span><span class="lineCov">        196 :   size_t x = 0;</span>
<span class="lineNum">      71 </span>            :   int b;
<span class="lineNum">      72 </span><span class="lineCov">        196 :   limit &gt;&gt;= 7;</span>
<span class="lineNum">      73 </span>            :   do {
<span class="lineNum">      74 </span><span class="lineCov">        211 :     b = LoadByte(S);</span>
<span class="lineNum">      75 </span><span class="lineCov">        210 :     if (x &gt;= limit)</span>
<span class="lineNum">      76 </span><span class="lineNoCov">          0 :       error(S, &quot;integer overflow&quot;);</span>
<span class="lineNum">      77 </span><span class="lineCov">        210 :     x = (x &lt;&lt; 7) | (b &amp; 0x7f);</span>
<span class="lineNum">      78 </span><span class="lineCov">        210 :   } while ((b &amp; 0x80) == 0);</span>
<span class="lineNum">      79 </span><span class="lineCov">        195 :   return x;</span>
<span class="lineNum">      80 </span>            : }
<span class="lineNum">      81 </span>            : 
<span class="lineNum">      82 </span>            : 
<span class="lineNum">      83 </span><span class="lineCov">         60 : static size_t LoadSize (LoadState *S) {</span>
<span class="lineNum">      84 </span><span class="lineCov">         60 :   return LoadUnsigned(S, ~(size_t)0);</span>
<span class="lineNum">      85 </span>            : }
<span class="lineNum">      86 </span>            : 
<span class="lineNum">      87 </span>            : 
<span class="lineNum">      88 </span><span class="lineCov">        136 : static int LoadInt (LoadState *S) {</span>
<span class="lineNum">      89 </span><span class="lineCov">        136 :   return cast_int(LoadUnsigned(S, INT_MAX));</span>
<span class="lineNum">      90 </span>            : }
<span class="lineNum">      91 </span>            : 
<span class="lineNum">      92 </span>            : 
<span class="lineNum">      93 </span><span class="lineCov">          9 : static lua_Number LoadNumber (LoadState *S) {</span>
<span class="lineNum">      94 </span>            :   lua_Number x;
<span class="lineNum">      95 </span><span class="lineCov">          9 :   LoadVar(S, x);</span>
<span class="lineNum">      96 </span><span class="lineCov">          9 :   return x;</span>
<span class="lineNum">      97 </span>            : }
<span class="lineNum">      98 </span>            : 
<span class="lineNum">      99 </span>            : 
<span class="lineNum">     100 </span><span class="lineCov">          9 : static lua_Integer LoadInteger (LoadState *S) {</span>
<span class="lineNum">     101 </span>            :   lua_Integer x;
<span class="lineNum">     102 </span><span class="lineCov">          9 :   LoadVar(S, x);</span>
<span class="lineNum">     103 </span><span class="lineCov">          9 :   return x;</span>
<span class="lineNum">     104 </span>            : }
<span class="lineNum">     105 </span>            : 
<span class="lineNum">     106 </span>            : 
<span class="lineNum">     107 </span>            : /*
<span class="lineNum">     108 </span>            : ** Load a nullable string
<span class="lineNum">     109 </span>            : */
<span class="lineNum">     110 </span><span class="lineCov">         60 : static TString *LoadStringN (LoadState *S) {</span>
<span class="lineNum">     111 </span><span class="lineCov">         60 :   size_t size = LoadSize(S);</span>
<span class="lineNum">     112 </span><span class="lineCov">         60 :   if (size == 0)</span>
<span class="lineNum">     113 </span><span class="lineCov">          6 :     return NULL;</span>
<span class="lineNum">     114 </span><span class="lineCov">         54 :   else if (--size &lt;= LUAI_MAXSHORTLEN) {  /* short string? */</span>
<span class="lineNum">     115 </span>            :     char buff[LUAI_MAXSHORTLEN];
<span class="lineNum">     116 </span><span class="lineCov">         54 :     LoadVector(S, buff, size);</span>
<span class="lineNum">     117 </span><span class="lineCov">         54 :     return luaS_newlstr(S-&gt;L, buff, size);</span>
<span class="lineNum">     118 </span>            :   }
<span class="lineNum">     119 </span>            :   else {  /* long string */
<span class="lineNum">     120 </span><span class="lineNoCov">          0 :     TString *ts = luaS_createlngstrobj(S-&gt;L, size);</span>
<span class="lineNum">     121 </span><span class="lineNoCov">          0 :     LoadVector(S, getstr(ts), size);  /* load directly in final place */</span>
<span class="lineNum">     122 </span><span class="lineNoCov">          0 :     return ts;</span>
<span class="lineNum">     123 </span>            :   }
<span class="lineNum">     124 </span>            : }
<span class="lineNum">     125 </span>            : 
<span class="lineNum">     126 </span>            : 
<span class="lineNum">     127 </span>            : /*
<span class="lineNum">     128 </span>            : ** Load a non-nullable string.
<span class="lineNum">     129 </span>            : */
<span class="lineNum">     130 </span><span class="lineCov">         32 : static TString *LoadString (LoadState *S) {</span>
<span class="lineNum">     131 </span><span class="lineCov">         32 :   TString *st = LoadStringN(S);</span>
<span class="lineNum">     132 </span><span class="lineCov">         32 :   if (st == NULL)</span>
<span class="lineNum">     133 </span><span class="lineNoCov">          0 :     error(S, &quot;bad format for constant string&quot;);</span>
<span class="lineNum">     134 </span><span class="lineCov">         32 :   return st;</span>
<span class="lineNum">     135 </span>            : }
<span class="lineNum">     136 </span>            : 
<span class="lineNum">     137 </span>            : 
<span class="lineNum">     138 </span><span class="lineCov">         11 : static void LoadCode (LoadState *S, Proto *f) {</span>
<span class="lineNum">     139 </span><span class="lineCov">         11 :   int n = LoadInt(S);</span>
<span class="lineNum">     140 </span><span class="lineCov">         11 :   f-&gt;code = luaM_newvectorchecked(S-&gt;L, n, Instruction);</span>
<span class="lineNum">     141 </span><span class="lineCov">         11 :   f-&gt;sizecode = n;</span>
<span class="lineNum">     142 </span><span class="lineCov">         11 :   LoadVector(S, f-&gt;code, n);</span>
<span class="lineNum">     143 </span><span class="lineCov">         11 : }</span>
<span class="lineNum">     144 </span>            : 
<span class="lineNum">     145 </span>            : 
<span class="lineNum">     146 </span>            : static void LoadFunction(LoadState *S, Proto *f, TString *psource);
<span class="lineNum">     147 </span>            : 
<span class="lineNum">     148 </span>            : 
<span class="lineNum">     149 </span><span class="lineCov">         11 : static void LoadConstants (LoadState *S, Proto *f) {</span>
<span class="lineNum">     150 </span>            :   int i;
<span class="lineNum">     151 </span><span class="lineCov">         11 :   int n = LoadInt(S);</span>
<span class="lineNum">     152 </span><span class="lineCov">         11 :   f-&gt;k = luaM_newvectorchecked(S-&gt;L, n, TValue);</span>
<span class="lineNum">     153 </span><span class="lineCov">         11 :   f-&gt;sizek = n;</span>
<span class="lineNum">     154 </span><span class="lineCov">         49 :   for (i = 0; i &lt; n; i++)</span>
<span class="lineNum">     155 </span><span class="lineCov">         38 :     setnilvalue(&amp;f-&gt;k[i]);</span>
<span class="lineNum">     156 </span><span class="lineCov">         49 :   for (i = 0; i &lt; n; i++) {</span>
<span class="lineNum">     157 </span><span class="lineCov">         38 :     TValue *o = &amp;f-&gt;k[i];</span>
<span class="lineNum">     158 </span><span class="lineCov">         38 :     int t = LoadByte(S);</span>
<span class="lineNum">     159 </span><span class="lineCov">         38 :     switch (t) {</span>
<span class="lineNum">     160 </span><span class="lineCov">          2 :       case LUA_TNIL:</span>
<span class="lineNum">     161 </span><span class="lineCov">          2 :         setnilvalue(o);</span>
<span class="lineNum">     162 </span><span class="lineCov">          2 :         break;</span>
<span class="lineNum">     163 </span><span class="lineNoCov">          0 :       case LUA_TBOOLEAN:</span>
<span class="lineNum">     164 </span><span class="lineNoCov">          0 :         setbvalue(o, LoadByte(S));</span>
<span class="lineNum">     165 </span><span class="lineNoCov">          0 :         break;</span>
<span class="lineNum">     166 </span><span class="lineCov">          2 :       case LUA_TNUMFLT:</span>
<span class="lineNum">     167 </span><span class="lineCov">          2 :         setfltvalue(o, LoadNumber(S));</span>
<span class="lineNum">     168 </span><span class="lineCov">          2 :         break;</span>
<span class="lineNum">     169 </span><span class="lineCov">          2 :       case LUA_TNUMINT:</span>
<span class="lineNum">     170 </span><span class="lineCov">          2 :         setivalue(o, LoadInteger(S));</span>
<span class="lineNum">     171 </span><span class="lineCov">          2 :         break;</span>
<span class="lineNum">     172 </span><span class="lineCov">         32 :       case LUA_TSHRSTR:</span>
<span class="lineNum">     173 </span>            :       case LUA_TLNGSTR:
<span class="lineNum">     174 </span><span class="lineCov">         32 :         setsvalue2n(S-&gt;L, o, LoadString(S));</span>
<span class="lineNum">     175 </span><span class="lineCov">         32 :         break;</span>
<span class="lineNum">     176 </span><span class="lineCov">         38 :       default: lua_assert(0);</span>
<span class="lineNum">     177 </span>            :     }
<span class="lineNum">     178 </span>            :   }
<span class="lineNum">     179 </span><span class="lineCov">         11 : }</span>
<span class="lineNum">     180 </span>            : 
<span class="lineNum">     181 </span>            : 
<span class="lineNum">     182 </span><span class="lineCov">         11 : static void LoadProtos (LoadState *S, Proto *f) {</span>
<span class="lineNum">     183 </span>            :   int i;
<span class="lineNum">     184 </span><span class="lineCov">         11 :   int n = LoadInt(S);</span>
<span class="lineNum">     185 </span><span class="lineCov">         11 :   f-&gt;p = luaM_newvectorchecked(S-&gt;L, n, Proto *);</span>
<span class="lineNum">     186 </span><span class="lineCov">         11 :   f-&gt;sizep = n;</span>
<span class="lineNum">     187 </span><span class="lineCov">         15 :   for (i = 0; i &lt; n; i++)</span>
<span class="lineNum">     188 </span><span class="lineCov">          4 :     f-&gt;p[i] = NULL;</span>
<span class="lineNum">     189 </span><span class="lineCov">         15 :   for (i = 0; i &lt; n; i++) {</span>
<span class="lineNum">     190 </span><span class="lineCov">          4 :     f-&gt;p[i] = luaF_newproto(S-&gt;L);</span>
<span class="lineNum">     191 </span><span class="lineCov">          4 :     LoadFunction(S, f-&gt;p[i], f-&gt;source);</span>
<span class="lineNum">     192 </span>            :   }
<span class="lineNum">     193 </span><span class="lineCov">         11 : }</span>
<span class="lineNum">     194 </span>            : 
<span class="lineNum">     195 </span>            : 
<span class="lineNum">     196 </span><span class="lineCov">         11 : static void LoadUpvalues (LoadState *S, Proto *f) {</span>
<span class="lineNum">     197 </span>            :   int i, n;
<span class="lineNum">     198 </span><span class="lineCov">         11 :   n = LoadInt(S);</span>
<span class="lineNum">     199 </span><span class="lineCov">         11 :   f-&gt;upvalues = luaM_newvectorchecked(S-&gt;L, n, Upvaldesc);</span>
<span class="lineNum">     200 </span><span class="lineCov">         11 :   f-&gt;sizeupvalues = n;</span>
<span class="lineNum">     201 </span><span class="lineCov">         24 :   for (i = 0; i &lt; n; i++)</span>
<span class="lineNum">     202 </span><span class="lineCov">         13 :     f-&gt;upvalues[i].name = NULL;</span>
<span class="lineNum">     203 </span><span class="lineCov">         24 :   for (i = 0; i &lt; n; i++) {</span>
<span class="lineNum">     204 </span><span class="lineCov">         13 :     f-&gt;upvalues[i].instack = LoadByte(S);</span>
<span class="lineNum">     205 </span><span class="lineCov">         13 :     f-&gt;upvalues[i].idx = LoadByte(S);</span>
<span class="lineNum">     206 </span>            :   }
<span class="lineNum">     207 </span><span class="lineCov">         11 : }</span>
<span class="lineNum">     208 </span>            : 
<span class="lineNum">     209 </span>            : 
<span class="lineNum">     210 </span><span class="lineCov">         11 : static void LoadDebug (LoadState *S, Proto *f) {</span>
<span class="lineNum">     211 </span>            :   int i, n;
<span class="lineNum">     212 </span><span class="lineCov">         11 :   n = LoadInt(S);</span>
<span class="lineNum">     213 </span><span class="lineCov">         11 :   f-&gt;lineinfo = luaM_newvectorchecked(S-&gt;L, n, ls_byte);</span>
<span class="lineNum">     214 </span><span class="lineCov">         11 :   f-&gt;sizelineinfo = n;</span>
<span class="lineNum">     215 </span><span class="lineCov">         11 :   LoadVector(S, f-&gt;lineinfo, n);</span>
<span class="lineNum">     216 </span><span class="lineCov">         11 :   n = LoadInt(S);</span>
<span class="lineNum">     217 </span><span class="lineCov">         11 :   f-&gt;abslineinfo = luaM_newvectorchecked(S-&gt;L, n, AbsLineInfo);</span>
<span class="lineNum">     218 </span><span class="lineCov">         11 :   f-&gt;sizeabslineinfo = n;</span>
<span class="lineNum">     219 </span><span class="lineCov">         11 :   for (i = 0; i &lt; n; i++) {</span>
<span class="lineNum">     220 </span><span class="lineNoCov">          0 :     f-&gt;abslineinfo[i].pc = LoadInt(S);</span>
<span class="lineNum">     221 </span><span class="lineNoCov">          0 :     f-&gt;abslineinfo[i].line = LoadInt(S);</span>
<span class="lineNum">     222 </span>            :   }
<span class="lineNum">     223 </span><span class="lineCov">         11 :   n = LoadInt(S);</span>
<span class="lineNum">     224 </span><span class="lineCov">         11 :   f-&gt;locvars = luaM_newvectorchecked(S-&gt;L, n, LocVar);</span>
<span class="lineNum">     225 </span><span class="lineCov">         11 :   f-&gt;sizelocvars = n;</span>
<span class="lineNum">     226 </span><span class="lineCov">         19 :   for (i = 0; i &lt; n; i++)</span>
<span class="lineNum">     227 </span><span class="lineCov">          8 :     f-&gt;locvars[i].varname = NULL;</span>
<span class="lineNum">     228 </span><span class="lineCov">         19 :   for (i = 0; i &lt; n; i++) {</span>
<span class="lineNum">     229 </span><span class="lineCov">          8 :     f-&gt;locvars[i].varname = LoadStringN(S);</span>
<span class="lineNum">     230 </span><span class="lineCov">          8 :     f-&gt;locvars[i].startpc = LoadInt(S);</span>
<span class="lineNum">     231 </span><span class="lineCov">          8 :     f-&gt;locvars[i].endpc = LoadInt(S);</span>
<span class="lineNum">     232 </span>            :   }
<span class="lineNum">     233 </span><span class="lineCov">         11 :   n = LoadInt(S);</span>
<span class="lineNum">     234 </span><span class="lineCov">         20 :   for (i = 0; i &lt; n; i++)</span>
<span class="lineNum">     235 </span><span class="lineCov">          9 :     f-&gt;upvalues[i].name = LoadStringN(S);</span>
<span class="lineNum">     236 </span><span class="lineCov">         11 : }</span>
<span class="lineNum">     237 </span>            : 
<span class="lineNum">     238 </span>            : 
<span class="lineNum">     239 </span><span class="lineCov">         11 : static void LoadFunction (LoadState *S, Proto *f, TString *psource) {</span>
<span class="lineNum">     240 </span><span class="lineCov">         11 :   f-&gt;source = LoadStringN(S);</span>
<span class="lineNum">     241 </span><span class="lineCov">         11 :   if (f-&gt;source == NULL)  /* no source in dump? */</span>
<span class="lineNum">     242 </span><span class="lineCov">          6 :     f-&gt;source = psource;  /* reuse parent's source */</span>
<span class="lineNum">     243 </span><span class="lineCov">         11 :   f-&gt;linedefined = LoadInt(S);</span>
<span class="lineNum">     244 </span><span class="lineCov">         11 :   f-&gt;lastlinedefined = LoadInt(S);</span>
<span class="lineNum">     245 </span><span class="lineCov">         11 :   f-&gt;numparams = LoadByte(S);</span>
<span class="lineNum">     246 </span><span class="lineCov">         11 :   f-&gt;is_vararg = LoadByte(S);</span>
<span class="lineNum">     247 </span><span class="lineCov">         11 :   f-&gt;maxstacksize = LoadByte(S);</span>
<span class="lineNum">     248 </span><span class="lineCov">         11 :   LoadCode(S, f);</span>
<span class="lineNum">     249 </span><span class="lineCov">         11 :   LoadConstants(S, f);</span>
<span class="lineNum">     250 </span><span class="lineCov">         11 :   LoadUpvalues(S, f);</span>
<span class="lineNum">     251 </span><span class="lineCov">         11 :   LoadProtos(S, f);</span>
<span class="lineNum">     252 </span><span class="lineCov">         11 :   LoadDebug(S, f);</span>
<span class="lineNum">     253 </span><span class="lineCov">         11 : }</span>
<span class="lineNum">     254 </span>            : 
<span class="lineNum">     255 </span>            : 
<span class="lineNum">     256 </span><span class="lineCov">         18 : static void checkliteral (LoadState *S, const char *s, const char *msg) {</span>
<span class="lineNum">     257 </span>            :   char buff[sizeof(LUA_SIGNATURE) + sizeof(LUAC_DATA)]; /* larger than both */
<span class="lineNum">     258 </span><span class="lineCov">         18 :   size_t len = strlen(s);</span>
<span class="lineNum">     259 </span><span class="lineCov">         18 :   LoadVector(S, buff, len);</span>
<span class="lineNum">     260 </span><span class="lineCov">         18 :   if (memcmp(s, buff, len) != 0)</span>
<span class="lineNum">     261 </span><span class="lineCov">          1 :     error(S, msg);</span>
<span class="lineNum">     262 </span><span class="lineCov">         17 : }</span>
<span class="lineNum">     263 </span>            : 
<span class="lineNum">     264 </span>            : 
<span class="lineNum">     265 </span><span class="lineCov">         21 : static void fchecksize (LoadState *S, size_t size, const char *tname) {</span>
<span class="lineNum">     266 </span><span class="lineCov">         21 :   if (LoadByte(S) != size)</span>
<span class="lineNum">     267 </span><span class="lineNoCov">          0 :     error(S, luaO_pushfstring(S-&gt;L, &quot;%s size mismatch&quot;, tname));</span>
<span class="lineNum">     268 </span><span class="lineCov">         21 : }</span>
<span class="lineNum">     269 </span>            : 
<span class="lineNum">     270 </span>            : 
<span class="lineNum">     271 </span>            : #define checksize(S,t)  fchecksize(S,sizeof(t),#t)
<span class="lineNum">     272 </span>            : 
<span class="lineNum">     273 </span><span class="lineCov">         11 : static void checkHeader (LoadState *S) {</span>
<span class="lineNum">     274 </span>            :   /* skip 1st char (already read and checked) */
<span class="lineNum">     275 </span><span class="lineCov">         11 :   checkliteral(S, &amp;LUA_SIGNATURE[1], &quot;not a binary chunk&quot;);</span>
<span class="lineNum">     276 </span><span class="lineCov">         10 :   if (LoadInt(S) != LUAC_VERSION)</span>
<span class="lineNum">     277 </span><span class="lineCov">          2 :     error(S, &quot;version mismatch&quot;);</span>
<span class="lineNum">     278 </span><span class="lineCov">          7 :   if (LoadByte(S) != LUAC_FORMAT)</span>
<span class="lineNum">     279 </span><span class="lineNoCov">          0 :     error(S, &quot;format mismatch&quot;);</span>
<span class="lineNum">     280 </span><span class="lineCov">          7 :   checkliteral(S, LUAC_DATA, &quot;corrupted chunk&quot;);</span>
<span class="lineNum">     281 </span><span class="lineCov">          7 :   checksize(S, Instruction);</span>
<span class="lineNum">     282 </span><span class="lineCov">          7 :   checksize(S, lua_Integer);</span>
<span class="lineNum">     283 </span><span class="lineCov">          7 :   checksize(S, lua_Number);</span>
<span class="lineNum">     284 </span><span class="lineCov">          7 :   if (LoadInteger(S) != LUAC_INT)</span>
<span class="lineNum">     285 </span><span class="lineNoCov">          0 :     error(S, &quot;integer format mismatch&quot;);</span>
<span class="lineNum">     286 </span><span class="lineCov">          7 :   if (LoadNumber(S) != LUAC_NUM)</span>
<span class="lineNum">     287 </span><span class="lineNoCov">          0 :     error(S, &quot;float format mismatch&quot;);</span>
<span class="lineNum">     288 </span><span class="lineCov">          7 : }</span>
<span class="lineNum">     289 </span>            : 
<span class="lineNum">     290 </span>            : 
<span class="lineNum">     291 </span>            : /*
<span class="lineNum">     292 </span>            : ** load precompiled chunk
<span class="lineNum">     293 </span>            : */
<span class="lineNum">     294 </span><span class="lineCov">         11 : LClosure *luaU_undump(lua_State *L, ZIO *Z, const char *name) {</span>
<span class="lineNum">     295 </span>            :   LoadState S;
<span class="lineNum">     296 </span>            :   LClosure *cl;
<span class="lineNum">     297 </span><span class="lineCov">         11 :   if (*name == '@' || *name == '=')</span>
<span class="lineNum">     298 </span><span class="lineCov">         11 :     S.name = name + 1;</span>
<span class="lineNum">     299 </span><span class="lineNoCov">          0 :   else if (*name == LUA_SIGNATURE[0])</span>
<span class="lineNum">     300 </span><span class="lineNoCov">          0 :     S.name = &quot;binary string&quot;;</span>
<span class="lineNum">     301 </span>            :   else
<span class="lineNum">     302 </span><span class="lineNoCov">          0 :     S.name = name;</span>
<span class="lineNum">     303 </span><span class="lineCov">         11 :   S.L = L;</span>
<span class="lineNum">     304 </span><span class="lineCov">         11 :   S.Z = Z;</span>
<span class="lineNum">     305 </span><span class="lineCov">         11 :   checkHeader(&amp;S);</span>
<span class="lineNum">     306 </span><span class="lineCov">          7 :   cl = luaF_newLclosure(L, LoadByte(&amp;S));</span>
<span class="lineNum">     307 </span><span class="lineCov">          7 :   setclLvalue2s(L, L-&gt;top, cl);</span>
<span class="lineNum">     308 </span><span class="lineCov">          7 :   luaD_inctop(L);</span>
<span class="lineNum">     309 </span><span class="lineCov">          7 :   cl-&gt;p = luaF_newproto(L);</span>
<span class="lineNum">     310 </span><span class="lineCov">          7 :   LoadFunction(&amp;S, cl-&gt;p, NULL);</span>
<span class="lineNum">     311 </span>            :   lua_assert(cl-&gt;nupvalues == cl-&gt;p-&gt;sizeupvalues);
<span class="lineNum">     312 </span>            :   luai_verifycode(L, buff, cl-&gt;p);
<span class="lineNum">     313 </span><span class="lineCov">          7 :   return cl;</span>
<span class="lineNum">     314 </span>            : }
<span class="lineNum">     315 </span>            : 
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.13</a></td></tr>
  </table>
  <br>

</body>
</html>
